package com.wxg.user.rest;

import com.alibaba.fastjson.JSON;
import com.wxg.common.core.module.user.dao.mysql.User;
import com.wxg.user.service.UserCacheService;
import com.wxg.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Administrator
 * @date: 2022/8/7 0:00
 * @desc:
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    private UserCacheService userCacheService;

    @GetMapping("/all")
    public void all(){
        List<User> userList = userService.queryAllUser();
        System.out.println(JSON.toJSONString(userList));
    }

    @GetMapping("/queryUserAndAddress")
    public void queryUserAndAddress(Long userId){
        System.out.println(JSON.toJSONString(userService.queryUserAndAddress(userId)));
    }

    @GetMapping("/getName")
    public void getName(Long userId){
        String name = userCacheService.queryUserWithCache(userId);
        System.out.println(name);
    }
}
